<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" %>
<%@ include file="../../common/layui.jsp" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<head>
    <title>可部署的流程</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
</head>
<body>

<div class="section_mian">
    <!-- 列表页 -->
    <div class="larry-personal">
        <div class="layui-tab">

            <!-- 功能区域 -->
            <blockquote class="layui-elem-quote news_search">
                <div class="layui-inline"><a class="layui-btn btn_color_zise" onclick="deploy()">部署</a></div>
            </blockquote>

            <form class="layui-form">
                <table class="layui-table" id="layuitable" lay-filter="tableFilter"></table>
            </form>

        </div>
    </div>
</div>

<script type="text/html" id="toolbar">
    <a class="layui-btn btn_color_huangse" lay-event="deploy" style="line-height: 25px;height: 25px;">部署</a>
</script>




<script type="text/javascript">
    function  reloadTable() {//刷新表格
        layui.table.reload('layuitable', {   where: {} });
    }
    layui.use(['laypage', 'layer', 'table', 'form', 'laydate'], function () {
        var laypage = layui.laypage
            , layer = layui.layer
            , table = layui.table
            , form = layui.form;
        var where = {};
        table.render({
            url: "act/deploy/gird1",
            method: 'post', //方式
            elem: '#layuitable', //数据表格渲染到什么位置
            id: 'layuitable', //生成 Layui table 的标识 id 用于操作数据用
            where: where, //默认 参数
            cols: [[
                {checkbox: true},
                //{field: "name", title: '名字', minWidth: 200},
                {field: "fullName", title: '流程名', minWidth: 200},
                {field: "opt", title: '操作', toolbar: '#toolbar', width: 200}
            ]],
            done: function (res, curr, count) {
                $("[data-field='id']").css('display','none');//隐藏列,[data-field='state']
            },
            page: false

        });
        //监听工具条
        table.on('tool(tableFilter)', function (obj) { //注：tool是工具条事件名，tableFilter是table原始容器的属性 lay-filter="对应的值"
            var data = obj.data; //获得当前行数据
            var layEvent = obj.event; //获得 lay-event 对应的值
            var tr = obj.tr; //获得当前行 tr 的DOM对象
            var fullName = data.fullName;
            if (layEvent === 'deploy') { //添加
                deploy( fullName );
            }
        });

    });


    //删除
    function deploy(processName) {
        var processNames = [];
        if(processName){//单个删除

        }else{//多
            var checkRows = layui.table.checkStatus('layuitable').data;//数组
            if(checkRows.length<=0){
                layer.msg('请选择要部署的流程！', {icon: 5});
                return;
            }
            for(var i in checkRows){
                processNames.push(checkRows[i].fullName);
            }
            processName = processNames.join(",");
        }
        parent.layer.confirm('确认要部署吗？', {
            btn : [ '确定', '取消' ]//按钮
        }, function(index) {
            //执行删除……
            $.ajax({
                url:"flow/deploy",
                type:"post",
                data:{"processName":processName},
                dataType:"json",
                success:function(data){
                    parent.layer.msg('部署成功！', {icon: 1});
                },
                error:function(data){
                    parent.layer.msg('系统异常！', {icon: 5});
                }
            });
        });
    }
</script>

</body>
</html>
